import { SEARCH_BLUR, SEARCH_FOCUS, CHANGE_LIST, MOUSE_ENTER, MOUSE_LEAVE, CHANGE_PAGE } from './actionTypes'
import axios from 'axios'
export function searchFocus() {
    return {
        type: SEARCH_FOCUS
    }
}
export const searchBlur = () => ({
    type: SEARCH_BLUR
})
export const changeList = (data) => ({
    type: CHANGE_LIST,
    data: data,
    totalPage: Math.ceil(data.length / 10)
})
export const mouseEnter = () => ({
    type: MOUSE_ENTER
})

export function mouseLeave() {
    return {
        type: MOUSE_LEAVE
    }
}
export function changePage(page) {
    return {
        type: CHANGE_PAGE,
        page
    }
}
export const getList = () => {
    return (dispatch) => {
        // console.log(123);
        axios.get('/api/headerList.json')
            .then(({ data }) => {
                // console.log(data.data)
                dispatch(changeList(data.data))
            })
            .catch(() => {
                console.log('error')
            })
    }
}